package com.zchat.android.receivers;

import com.zchat.android.app.LauncherApplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

/**
 * 
 * @author Oliverzhu
 * 2012/6/25
 */
public class LoggedInOutBroadcastReceiver extends BroadcastReceiver {
	private Context context;
	public static final String INTENT_ACTION_LOGGED_OUT = "com.zchat.intent.action.LOGGED_OUT";
    public static final String INTENT_ACTION_LOGGED_IN = "com.zchat.intent.action.LOGGED_IN";

	@Override
	public void onReceive(Context context, Intent intent) {
		 if (INTENT_ACTION_LOGGED_IN.equals(intent.getAction())) {
             ((LauncherApplication)context).requestUpdateUser();
         }
	}
	
	public void register(Context context)
	{
		this.context = context;
		IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(INTENT_ACTION_LOGGED_IN);
        intentFilter.addAction(INTENT_ACTION_LOGGED_OUT);
        context.registerReceiver(this, intentFilter);
	}

}
